#include<iostream>
using namespace std;
const int N = 2e5 + 10;
int p[N], sz[N], ans[N];
int n, m;
int find(int x)
{
	if (x != p[x]) p[x] = find(p[x]);
	return p[x];
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		p[i] = i;
		sz[i] = 1;
	}
	while (m--) {
		int a, b;
		cin >> a >> b;
		int a1 = find(a);
		int b1 = find(b);
		if (a1 != b1) {
			p[a1] = b1;
			sz[b1] += sz[a1];
			ans[b1] += ans[a1];
			ans[b1]++;
		}
		else {
			ans[a1]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (p[i] == i && ans[i] != sz[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}